package com.leetcode.No0477;

/**
 * @program: leetcode
 * @description:
 * @author: wangzhihua
 * @date: 2021-05-29
 */
public class Solution2 {
	public int totalHammingDistance(int[] nums) {
		int ans = 0;
		for (int i = 0; i < 32; ++i) {
			int tmp = 0;
			for (int j = 0; j < nums.length; ++j) {
				tmp += ((nums[j] >> i) & 1);
			}
			ans += (nums.length - tmp) * tmp;
		}
		return ans;
	}
}
